"use strict";
const common_vendor = require("../../common/vendor.js");
const common_url = require("../../common/url.js");
const common_api = require("../../common/api.js");
require("../../common/request.js");
const zeroWaterfall = () => "../../uni_modules/zero-waterfall/components/zero-waterfall/zero-waterfall.js";
const tabBar = () => "../../components/tab-bar/tab-bar.js";
const _sfc_main = {
  components: {
    zeroWaterfall,
    tabBar
  },
  data() {
    return {
      arr: [],
      loading: false,
      dataList: [],
      loadStatus: "more",
      page: 1,
      pageSize: 5,
      sortType: 0,
      sort: 0,
      happyCountIcon: common_url.Icons.DownSort,
      helpCountIcon: common_url.Icons.DownSort,
      searchIcon: common_url.Icons.Search,
      plantIcon: common_url.Icons.GreenPlant,
      count: {
        isChecked: false,
        happyClickCount: 0,
        helpClickCount: 0
      },
      isRefreshing: true,
      searchValue: ""
    };
  },
  onPullDownRefresh() {
    setTimeout(() => {
      common_vendor.index.stopPullDownRefresh();
    }, 200);
    this.refresh();
  },
  onLoad() {
    this.refresh();
  },
  onReachBottom() {
    this.getOneNewPageConsultants();
  },
  methods: {
    onClickSearch() {
      console.log(this.searchValue);
      this.refresh();
    },
    onKeyBoardSearch() {
      this.onClickSearch();
    },
    refresh() {
      this.page = 0;
      this.dataList = [];
      common_vendor.index.showLoading({
        "title": "正在加载中"
      });
      this.isRefreshing = true;
      this.getOneNewPageConsultants();
    },
    getOneNewPageConsultants() {
      common_api.getConsultants({
        page: this.page++,
        pageSize: 5,
        sortType: this.sortType,
        sort: this.sort,
        searchValue: this.searchValue
      }).then((res) => {
        console.log(res);
        this.dataList = this.dataList.concat(res.data.consultants);
        console.log(this.dataList);
        setTimeout(() => {
          common_vendor.index.hideLoading();
          this.isRefreshing = false;
        }, 1e3);
      });
    },
    visitorsHappyCount() {
      this.count.happyClickCount++;
      this.updateSort(0);
    },
    helpVisitorsCount() {
      this.count.helpClickCount++;
      this.updateSort(1);
    },
    isAvailable() {
      this.count.isChecked = true;
      this.updateSort(2);
    },
    updateSort(type) {
      this.sortType = type;
      const {
        happyClickCount,
        helpClickCount,
        isChecked
      } = this.count;
      if (type === 0) {
        this.happyCountIcon = happyClickCount % 2 === 0 ? common_url.Icons.DownSort : common_url.Icons.UpSort;
        this.sort = happyClickCount % 2 === 0 ? 0 : 1;
        this.count.isChecked = false;
        console.log("用户满意度" + this.sort);
      } else if (type === 1) {
        this.helpCountIcon = helpClickCount % 2 === 0 ? common_url.Icons.DownSort : common_url.Icons.UpSort;
        this.sort = helpClickCount % 2 === 0 ? 0 : 1;
        this.count.isChecked = false;
        console.log("帮助用户数" + this.sort);
      } else {
        console.log("是否空闲" + this.sort);
      }
      this.refresh();
    }
  }
};
if (!Array) {
  const _easycom_zero_waterfall2 = common_vendor.resolveComponent("zero-waterfall");
  const _easycom_tab_bar2 = common_vendor.resolveComponent("tab-bar");
  (_easycom_zero_waterfall2 + _easycom_tab_bar2)();
}
const _easycom_zero_waterfall = () => "../../uni_modules/zero-waterfall/components/zero-waterfall/zero-waterfall.js";
const _easycom_tab_bar = () => "../../components/tab-bar/tab-bar.js";
if (!Math) {
  (_easycom_zero_waterfall + _easycom_tab_bar)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.t($data.plantIcon),
    b: common_vendor.o((...args) => $options.onKeyBoardSearch && $options.onKeyBoardSearch(...args)),
    c: $data.searchValue,
    d: common_vendor.o(($event) => $data.searchValue = $event.detail.value),
    e: common_vendor.t($data.searchIcon),
    f: common_vendor.n($data.sortType === 0 ? "main-font" : "normal-font"),
    g: common_vendor.t($data.happyCountIcon),
    h: common_vendor.n($data.sortType === 0 ? "main-font" : "normal-font"),
    i: common_vendor.o((...args) => $options.visitorsHappyCount && $options.visitorsHappyCount(...args)),
    j: common_vendor.n($data.sortType === 1 ? "main-font" : "normal-font"),
    k: common_vendor.t($data.helpCountIcon),
    l: common_vendor.n($data.sortType === 1 ? "main-font" : "normal-font"),
    m: common_vendor.o((...args) => $options.helpVisitorsCount && $options.helpVisitorsCount(...args)),
    n: common_vendor.n($data.sortType === 2 ? "main-font" : "normal-font"),
    o: $data.count.isChecked,
    p: common_vendor.o((...args) => $options.isAvailable && $options.isAvailable(...args)),
    q: common_vendor.o((...args) => $options.isAvailable && $options.isAvailable(...args)),
    r: !$data.isRefreshing
  }, !$data.isRefreshing ? {
    s: common_vendor.p({
      list: $data.dataList
    })
  } : {}, {
    t: common_vendor.p({
      activeIndex: "0"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "D:/Project/heart-3.0/heart-field-3.0/pages/index/index.vue"]]);
wx.createPage(MiniProgramPage);
